<!DOCTYPE html>

<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <title></title>
  <meta name="description" content="" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <script src="./cdn/vue/2.5.2/vue.min.js"></script>
  <link rel="stylesheet" href="./cdn/element-ui/2.9.1/theme-chalk/index.css" />
  <link rel="stylesheet" href="./css/iconfont/iconfont.css">
  <link rel="stylesheet" href="./css/common.css">
  <link rel="stylesheet" href="./css/list.css">
  <script src="./cdn/element-ui/2.9.1/index.js"></script>

  <head>
    <meta charset="utf-8">
    <title></title>
  </head>

<body>
  <div id="app">
    <el-container>
      <el-header>
        <el-menu :default-active="activeName" mode="horizontal" background-color="#171b22" text-color="#fff"
          active-text-color="#00baff" @select="handleSelect">
          <el-menu-item index="0">
            <i class="iconfont icon-daping"></i>
            模板库
          </el-menu-item>
          <el-menu-item index="1">
            <i class="iconfont icon-moban"></i>
            组件库
          </el-menu-item>
        </el-menu>
      </el-header>
      <el-main>
        <div class="content">
          <div class="content__item content__item--add">
            <a href="./build.html" target="_blank">
              <i class="el-icon-plus"></i>
              <p>新建大屏</p>
            </a>
          </div>
          <div class="content__item" v-for="(item,index) in list" :key="index" @mouseover="item._menu=true"
            @mouseout="item._menu=false">
            <div class="content__info">
              <img v-if="item.img" :src="item.img" alt="" />
              <div class="content__menu" v-if="item._menu">
                <a class="content__btn" :href="item.href?item.href:'./build.html?id='+item.id" target="_blank">编辑</a>
              </div>
            </div>
            <div class="content__main">
              <span class="content__name">{{item.label}}</span>
              <div>
                <a class="content__view" :href="item.href?item.href:'./view.html?id='+item.id" target="_blank">
                  <i class="el-icon-view"></i>
                  预览
                </a>
                <span class="content__status" :class="{'content__status--active':item.status}">
                  <i class="el-icon-check"></i>
                  {{item.status?'已发布':'未发布'}}
                </span>
              </div>

            </div>
          </div>
        </div>
      </el-main>
    </el-container>
  </div>
</body>
<script>
  new Vue({
    el: '#app',
    data() {
      return {
        activeName: '0',
        list: [],
        list0: [{
          id: 3,
          img: './data/data3.jpg',
          label: "大屏模版1",
          status: true
        }, {
          id: 0,
          img: './data/data0.jpg',
          label: "大屏模版2",
          status: true
        }, {
          id: 1,
          img: './data/data1.jpg',
          label: "大屏模版3",
          status: false
        }, {
          id: 9,
          img: './data/data9.jpg',
          label: "大屏模版4",
          status: false
        }, {
          id: 2,
          img: './data/data.jpg',
          href: './wel.html',
          label: "动态演示",
          status: false
        }],
        list1: [{
          id: 2,
          img: './data/data2.jpg',
          label: "滑动组件",
          status: false
        }, {
          id: 4,
          img: './data/data4.jpg',
          label: "自定义组件",
          status: false
        }, {
          id: 5,
          img: './data/data5.jpg',
          label: "数据格式化",
          status: false
        }, {
          id: 6,
          img: './data/data6.jpg',
          label: "提示语格式化",
          status: false
        }, {
          id: 7,
          img: './data/data7.jpg',
          label: "选项卡例子",
          status: false
        }, {
          id: 8,
          img: './data/data8.jpg',
          label: "水印例子",
          status: false
        }]
      }
    },
    watch: {
      activeName: {
        handler(val) {
          {
            this.list = this['list' + val]
            this.initData();
          }
        },
        immediate: true
      }
    },
    methods: {
      handleSelect(key, keyPath) {
        this.activeName = key;
      },
      initData() {
        this.list.forEach((ele, index) => {
          this.$set(this.list[index], '_menu', false)
        })
      }
    }
  })
</script>

</html>